package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.ZtfLearningAdmin;
import com.ruoyi.system.service.IZtfLearningAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学科分类Controller
 * 
 * @author ruoyi
 * @date 2025-05-29
 */
@RestController
@RequestMapping("app/system/admin")
@Api(tags = "app学堂相关接口")
public class ZtfLearningAdminController extends BaseController
{
    @Autowired
    private IZtfLearningAdminService ztfLearningAdminService;

    /**
     * 查询学科分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:admin:list')")
    @GetMapping("/list")
    @ApiOperation("学科分类列表")
    public TableDataInfo list(ZtfLearningAdmin ztfLearningAdmin)
    {
        startPage();
        List<ZtfLearningAdmin> list = ztfLearningAdminService.selectZtfLearningAdminList(ztfLearningAdmin);
        return getDataTable(list);
    }

    /**
     * 导出学科分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:admin:export')")
    @Log(title = "学科分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZtfLearningAdmin ztfLearningAdmin)
    {
        List<ZtfLearningAdmin> list = ztfLearningAdminService.selectZtfLearningAdminList(ztfLearningAdmin);
        ExcelUtil<ZtfLearningAdmin> util = new ExcelUtil<ZtfLearningAdmin>(ZtfLearningAdmin.class);
        util.exportExcel(response, list, "学科分类数据");
    }

    /**
     * 获取学科分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:admin:query')")
    @GetMapping(value = "/{sdId}")
    public AjaxResult getInfo(@PathVariable("sdId") Long sdId)
    {
        return success(ztfLearningAdminService.selectZtfLearningAdminBySdId(sdId));
    }

    /**
     * 新增学科分类
     */
    @PreAuthorize("@ss.hasPermi('system:admin:add')")
    @Log(title = "学科分类", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("学堂新增接口")
    public AjaxResult add(@RequestBody ZtfLearningAdmin ztfLearningAdmin)
    {
        return toAjax(ztfLearningAdminService.insertZtfLearningAdmin(ztfLearningAdmin));
    }

    /**
     * 修改学科分类
     */
    @PreAuthorize("@ss.hasPermi('system:admin:edit')")
    @Log(title = "学科分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZtfLearningAdmin ztfLearningAdmin)
    {
        return toAjax(ztfLearningAdminService.updateZtfLearningAdmin(ztfLearningAdmin));
    }

    /**
     * 删除学科分类
     */
    @ApiOperation("学堂删除接口")
    @PreAuthorize("@ss.hasPermi('system:admin:remove')")
    @Log(title = "学科分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sdIds}")
    public AjaxResult remove(@PathVariable String[] sdIds)
    {
        return toAjax(ztfLearningAdminService.deleteZtfLearningAdminBySdIds(sdIds));
    }
}
